<?php
/**
 * Create By: PhpStorm
 * User: niechenguang
 * File: GetCircle.php
 * Date: 2017/1/2
 * Time: 23:13
 */

namespace app\api\model\page\circle;

use app\api\model\dao\Circle;
use app\api\model\dao\CircleCategory;
use app\api\model\data\circle\CircleData;
use app\library\Error;
use app\library\Flag;
use app\library\PageBase;
use think\Exception;
use think\Validate;

class GetMineCircleList extends PageBase
{

    private $objCircle;
    private $objCircleCategory;
    private $objCircleData;

    public function __construct()
    {
        parent::__construct();

        $this->objCircle = new Circle();
        $this->objCircleCategory = new CircleCategory();
        $this->objCircleData = new CircleData();

    }

    /**
     * page 入口
     *
     * @param $param
     * @return array
     * @throws Exception
     */
    public function excute($param)
    {
        $ret = $this->checkToken($param);
        if (false === $ret) {
            return $this->getRes(Error::ERR_NO_AUTH);
        }

        if (isset($param['cir_id']) && !empty($param['cir_id'])) {
            $mine_cir_id = $param['cir_id'];
            $circle_list_cur = $this->objCircleData->getCircleByid($mine_cir_id);
            if (!empty($circle_list_cur)) {
                $this->data['circle_current'] = $circle_list_cur[0];
            }
        }

        $this->data['list'] = $this->objCircleData->followCircle($this->user_id, 0, 1000);

        return $this->getRes();
    }
}
